<?php

/**
 * This is the model class for table "lths_dayreport".
 *
 * The followings are the available columns in table 'lths_dayreport':
 * @property integer $calc_day
 * @property string $report_id
 * @property string $eparchy_code
 * @property string $depart_code
 * @property string $product_id
 * @property string $varchar1
 * @property string $varchar2
 * @property string $varchar3
 * @property string $varchar4
 * @property string $varchar5
 * @property string $varchar6
 * @property string $varchar7
 * @property string $varchar8
 * @property string $varchar9
 * @property string $varchar10
 * @property string $varchar11
 * @property string $varchar12
 * @property string $varchar13
 * @property string $varchar14
 * @property string $varchar15
 * @property string $varchar16
 * @property string $varchar17
 * @property string $varchar18
 * @property string $varchar19
 * @property string $varchar20
 * @property integer $num1
 * @property integer $num2
 * @property integer $num3
 * @property integer $num4
 * @property integer $num5
 * @property integer $num6
 * @property integer $num7
 * @property integer $num8
 * @property integer $num9
 * @property integer $num10
 * @property integer $id
 *
 * The followings are the available model relations:
 * @property Depart $departCode
 * @property Eparchy $eparchyCode
 * @property Product $product
 */
class Dayreport extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Dayreport the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'lths_dayreport';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('calc_day', 'required'),
			array('calc_day, num1, num2, num3, num4, num5, num6, num7, num8, num9, num10', 'numerical', 'integerOnly'=>true),
			array('report_id, varchar1, varchar2, varchar3, varchar4, varchar5, varchar6, varchar7, varchar8, varchar9, varchar10, varchar11, varchar12, varchar13, varchar14, varchar15, varchar16, varchar17, varchar18, varchar19, varchar20', 'length', 'max'=>50),
			array('eparchy_code', 'length', 'max'=>4),
			array('depart_code', 'length', 'max'=>20),
			array('product_id', 'length', 'max'=>15),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('calc_day, report_id, eparchy_code, depart_code, product_id, varchar1, varchar2, varchar3, varchar4, varchar5, varchar6, varchar7, varchar8, varchar9, varchar10, varchar11, varchar12, varchar13, varchar14, varchar15, varchar16, varchar17, varchar18, varchar19, varchar20, num1, num2, num3, num4, num5, num6, num7, num8, num9, num10, id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'departCode' => array(self::BELONGS_TO, 'Depart', 'depart_code'),
			'eparchyCode' => array(self::BELONGS_TO, 'Eparchy', 'eparchy_code'),
			'product' => array(self::BELONGS_TO, 'Product', 'product_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'calc_day' => 'Calc Day',
			'report_id' => 'Report',
			'eparchy_code' => '地市',
			'depart_code' => '营业厅',
			'product_id' => '产品编码',
			'varchar1' => 'Varchar1',
			'varchar2' => 'Varchar2',
			'varchar3' => 'Varchar3',
			'varchar4' => 'Varchar4',
			'varchar5' => 'Varchar5',
			'varchar6' => 'Varchar6',
			'varchar7' => 'Varchar7',
			'varchar8' => 'Varchar8',
			'varchar9' => 'Varchar9',
			'varchar10' => 'Varchar10',
			'varchar11' => 'Varchar11',
			'varchar12' => 'Varchar12',
			'varchar13' => 'Varchar13',
			'varchar14' => 'Varchar14',
			'varchar15' => 'Varchar15',
			'varchar16' => 'Varchar16',
			'varchar17' => 'Varchar17',
			'varchar18' => 'Varchar18',
			'varchar19' => 'Varchar19',
			'varchar20' => 'Varchar20',
			'num1' => '期初库存',
			'num2' => '期末库存',
			'num3' => '进货数',
			'num4' => '外借数',
			'num5' => '售后数',
			'num6' => '销售数',
			'num7' => 'Num7',
			'num8' => 'Num8',
			'num9' => 'Num9',
			'num10' => 'Num10',
			'id' => 'ID',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('calc_day',$this->calc_day);
		$criteria->compare('report_id',$this->report_id,true);
		$criteria->compare('eparchy_code',$this->eparchy_code,true);
		$criteria->compare('depart_code',$this->depart_code,true);
		$criteria->compare('product_id',$this->product_id,true);
		$criteria->compare('varchar1',$this->varchar1,true);
		$criteria->compare('varchar2',$this->varchar2,true);
		$criteria->compare('varchar3',$this->varchar3,true);
		$criteria->compare('varchar4',$this->varchar4,true);
		$criteria->compare('varchar5',$this->varchar5,true);
		$criteria->compare('varchar6',$this->varchar6,true);
		$criteria->compare('varchar7',$this->varchar7,true);
		$criteria->compare('varchar8',$this->varchar8,true);
		$criteria->compare('varchar9',$this->varchar9,true);
		$criteria->compare('varchar10',$this->varchar10,true);
		$criteria->compare('varchar11',$this->varchar11,true);
		$criteria->compare('varchar12',$this->varchar12,true);
		$criteria->compare('varchar13',$this->varchar13,true);
		$criteria->compare('varchar14',$this->varchar14,true);
		$criteria->compare('varchar15',$this->varchar15,true);
		$criteria->compare('varchar16',$this->varchar16,true);
		$criteria->compare('varchar17',$this->varchar17,true);
		$criteria->compare('varchar18',$this->varchar18,true);
		$criteria->compare('varchar19',$this->varchar19,true);
		$criteria->compare('varchar20',$this->varchar20,true);
		$criteria->compare('num1',$this->num1);
		$criteria->compare('num2',$this->num2);
		$criteria->compare('num3',$this->num3);
		$criteria->compare('num4',$this->num4);
		$criteria->compare('num5',$this->num5);
		$criteria->compare('num6',$this->num6);
		$criteria->compare('num7',$this->num7);
		$criteria->compare('num8',$this->num8);
		$criteria->compare('num9',$this->num9);
		$criteria->compare('num10',$this->num10);
		$criteria->compare('id',$this->id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}